package com.siwei.mes.entity.orderDetail;

import com.alibaba.fastjson.JSONObject;
import com.siwei.mes.common.util.JsonUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @Description: 工单详情图片或视频
 * @Version: 1.0
 * @author: chenmaolin
 * @date: 2023/12/10 20:35
 */
@Data
public class DetailFile {
    @ApiModelProperty(value = "图片")
    private String img = "";

    @ApiModelProperty(value = "视频")
    private String video = "";

    /**
     * 字符串转成对象 然后再转成json
     *
     * @param object
     * @return
     */
    public static JSONObject toJsonObject(Object object) {
        DetailFile entity = new DetailFile();
        if (object == null) {
            return JsonUtils.beanToObject(entity);
        }
        if (object instanceof String) {
            entity = JsonUtils.getObject((String) object, DetailFile.class);
        } else if (object instanceof JSONObject) {
            entity = JsonUtils.getObject((JSONObject) object, DetailFile.class);
        }
        return JsonUtils.beanToObject(entity);
    }
}
